﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Web.UI.WebControls;
using Fishing.Dal;
using Fishing.Model;

namespace Fishing.Admin
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            var userID = txtUserID.Text.Trim();
            var password = txtPassword.Text.Trim();

            var where =" and userID='"+userID+ "' and `password`='"+password+"' ";

            var _dal=new AdminUserRoleDal();
            var list = _dal.GetRoleDataBy(where);
            if (list.Count > 0)
            {
                if (list[0].status != "001")
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "提示",
                        "<script type='text/javascript'>alert('用户未启用！');</script>");
                }
                else
                {
                    //跳转
                    Session["UserID"] = userID;
                    Response.Redirect("User.aspx");
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "提示",
                    "<script type='text/javascript'>alert('用户或密码有误！');</script>");
            }

        }
    }
}